package com.mindao.app.ued.controller;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSON;
import com.mindao.app.common.spring.controller.BaseBaseController;
import com.mindao.app.common.spring.service.util.JsonResult;

/**
/* 版权所有： 广州敏道科技有限公司
/*
/* 功能描述：图表demo
/*
/* 创 建 人：李国才
/* 创建时间：2016年7月11日 下午2:25:47 	
 **/
@Controller
@RequestMapping("/ued/chart")
public class ChartController  extends BaseBaseController{
	/**
	 * 进入echart演示页面
	 * @param request
	 * @param response
	 * @param session
	 * @param rhs
	 * @return
	 */
	@RequestMapping
	public String echartDemo( HttpServletRequest request,HttpServletResponse response,HttpSession session,Model rhs){
		return super.rtnDefault(request, response, session, rhs);
	}
	/**
	 * 获取echart演示数据
	 * @param request
	 * @param response
	 * @param session
	 * @param rhs
	 * @return
	 */
	@ResponseBody
	@RequestMapping
	public JsonResult getDemoData( HttpServletRequest request,HttpServletResponse response,HttpSession session,Model rhs){
		Map<String,Object> chartData=new HashMap<>();
		
		chartData.put("xData", new String[]{"衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"});
		chartData.put("seriesData",new Integer[]{5, 20, 36, 10, 10, 20});
		JsonResult jr =new JsonResult(JsonResult.SUCCESS,null,chartData );
		return jr;
	}
	public static void main(String[] args) {
		String[] types=new String[]{"衬衫","羊毛衫","雪纺衫","裤子","高跟鞋","袜子"};
		String s1=JSON.toJSONString(types);
		System.out.println(s1);
		
		List<String> l2=new ArrayList<String>();
		l2.addAll(Arrays.asList(types));
		String s2=JSON.toJSONString(l2);
		System.out.println(s2);
	}
}
